package com.xhx.accounting;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;

public class loan_result extends AppCompatActivity {
    private ListView loanList;
    private loanAdapter mAdapter;
    private TextView monthMoney,totalMoney,rate,month;
    private DecimalFormat decimalFormat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loan_result);
        loanList = findViewById(R.id.loan_list);
        Intent intent = getIntent();
        Map<String,Object> loanResult = (Map<String,Object>)intent.getSerializableExtra("loan_result");
        List<Map<String,Object>> data = (List)loanResult.get("everyMonthData");
        mAdapter = new loanAdapter(this,data);
        loanList.setAdapter(mAdapter);
        monthMoney = findViewById(R.id.month_money1);
        totalMoney = findViewById(R.id.total_money);
        rate = findViewById(R.id.rate2);
        month = findViewById(R.id.month3);
        decimalFormat = new DecimalFormat("0.00");
        monthMoney.setText(decimalFormat.format(loanResult.get("everyMonthTotal")));
        totalMoney.setText(String.valueOf((int)loanResult.get("money")/10000) + "万元");
        month.setText(String.valueOf(loanResult.get("month")));
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.arrow_left:
                finish();
                break;
        }
    }
}